package com.bbcare.img.plat.service.impl;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bbcare.comm.*;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.bbcare.img.plat.entity.ContentTemplVersion;
import com.bbcare.img.plat.entity.AiImg;
import com.bbcare.img.plat.entity.AiImgMark;
import com.bbcare.img.plat.entity.AiImgMarkData;
import com.bbcare.img.plat.entity.AiMarkTempl;
import com.bbcare.img.plat.service.IImgMarkService;
import com.bbcare.img.plat.store.ibatis.IIaOperationRecordDAO;
import com.bbcare.img.plat.store.ibatis.IImgDAO;
import com.bbcare.img.plat.store.ibatis.IImgMarkDAO;
import com.bbcare.img.plat.store.ibatis.IImgMarkDataDAO;
import com.bbcare.img.plat.store.ibatis.IMarkTemplDAO;

/**
 * @name: 影像文件标记服务接口实现
 * @author: DemonLee
 * @createTime: 2017.11.1
 * @description: 影像文件标记相关操作，包括增加，修改及查询等
 * @modify:
 *
 */
@Service
public class ImgMarkServiceImpl implements IImgMarkService {
    private final Log logger = LogFactory.getLog(ImgMarkServiceImpl.class);

    @Autowired
    private IImgMarkDAO imgMarkDao;

    @Autowired
    private IImgMarkDataDAO imgMarkDataDao;

    @Autowired
    private IImgDAO imgDao;

    @Autowired
    private IMarkTemplDAO markTemplDao;

    @Autowired
    private IIaOperationRecordDAO iaOperationRecordDao;

    // 影像文件标记记录查询接口实现
    public Map<String, Object> listImgMarkRecord(Map<String, Object> mapIn) throws Exception {
        logger.debug("mapIn==" + mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        int total = 0;
        mapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        List<AiImgMark> imgMarkList = imgMarkDao.listImgMarkByCondition(mapIn);
        outMap.put("rows", imgMarkList);
        if (CollectionUtils.isNotEmpty(imgMarkList)) {
            total = imgMarkList.size();
        }
        outMap.put("total", total);

        return outMap;
    }

    // 影像文件标记记录详情查询接口实现
    public Map<String, Object> listImgMarkData(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> outMap = new HashMap<String, Object>();

        // 校验标记记录是否存在
        Map<String, Object> qryMapIn = new HashMap<String, Object>();
        qryMapIn.put("id", (String) mapIn.get("markId"));
        qryMapIn.put("tenantId", (String) mapIn.get("tenantId"));
        qryMapIn.put("imgId", (String) mapIn.get("imgId"));
        qryMapIn.put("userId", (String) mapIn.get("userId"));
        qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        List<AiImgMark> imgMarkList = imgMarkDao.listImgMarkByCondition(qryMapIn);
        if (CollectionUtils.isEmpty(imgMarkList)) {
            throw (new AppException(ErrorCode.IMG_EXCEPTION_IMGMARK_NOT_EXISTS, "未查询到对应的标记记录，处理失败！"));
        }

        List<AiImgMarkData> imdList = imgMarkDataDao.listImgMarkDataByCondition(mapIn);
        if (CollectionUtils.isNotEmpty(imdList)) {
            int m = 0;
            int msize = imdList.size();
            AiImgMarkData imgMarkData = new AiImgMarkData();
            for (m = 0; m < msize; m++) {
                imgMarkData = imdList.get(m);
                outMap.put(imgMarkData.getDataId(), imgMarkData.getDataValue());
            }
        }

        return outMap;
    }

    // 影像文件标记模板查询接口实现
    public Map<String, Object> listMarkTempl(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> outMap = new HashMap<String, Object>();
        mapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        List<AiMarkTempl> markTemplList = markTemplDao.listMarkTemplByCondition(mapIn);
        outMap.put("rows", markTemplList);
        int total = 0;
        if (CollectionUtils.isNotEmpty(markTemplList)) {
            total = markTemplList.size();
        }
        outMap.put("total", total);

        return outMap;
    }

    // 影像文件标记模板问卷内容查询接口实现
    public Map<String, Object> listMarkTemplCont(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> outMap = new HashMap<String, Object>();
        List<Object> conDataList = new ArrayList<Object>();
        String templId = (String) mapIn.get("templId");
        Integer templVersion = (Integer) mapIn.get("templVersion");

        // 获取内容模板
        HashMap<String, Object> contVerMap = new HashMap<String, Object>();
        contVerMap.put("templId", templId);
        contVerMap.put("templVersion", templVersion);
        List<ContentTemplVersion> ctvList = markTemplDao.listContentDataByTempl(contVerMap);
        if (CollectionUtils.isEmpty(ctvList)) {
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_QUES_TEMPL_NOT_EXIST, "未查询到标记模板版本记录！");
        }
        ContentTemplVersion ctv = ctvList.get(0);

        String templDataStr = ctv.getTemplData();
        if (StringUtils.isEmpty(templDataStr)) {
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_QUES_TEMPLDATA_IS_NULL, "标记模板内容为空！");
        }

        // 数据库默认配置为json数组格式
        JSONArray templJsonArray = null;
        try {
            templJsonArray = JSON.parseArray(templDataStr);
            conDataList.add(templJsonArray);
        } catch (JSONException arex) {
            logger.error("任务内容模板格式配置错误，非json数组格式： " + arex.getMessage());

            // 非json数组格式，则按json格式再解析
            JSONObject templJsonObject = null;
            try {
                templJsonObject = JSON.parseObject(templDataStr);
                conDataList.add(templJsonObject);
            } catch (JSONException exobj) {
                exobj.printStackTrace();
                // 后续重写异常类
                throw (new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_QUES_TEMPLDATA_CONFIG_IRREGULAR,
                        "问卷模板配置错误，非json格式！"));
            }
        } catch (AppException appex) {
            throw (appex);
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new AppException(ErrorCode.FOLLOWUP_EXCEPTION_TYPE_QUES_TEMPLDATA_CONFIG_IRREGULAR,
                    "问卷模板格式解析错误：" + ex.getMessage());
        }
        outMap.put("questiones", conDataList);

        return outMap;
    }

    // 影像文件标记添加或修改接口实现
    @Transactional
    public Map<String, Object> conductImgMark(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        List<Map<String, Object>> markList = ToolUtil.typeCast(argMap.get("markList"));
        if (CollectionUtils.isEmpty(markList)) {
            return outMap;
        }
        Map<String, Object> sessionInfo = ToolUtil.typeCast(argMap.get("sessionInfo"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        // 文件信息校验
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        String imgId = (String) fileInfo.get("imgId");
        String tenantId = (String) sessionInfo.get("tenantId");
        Map<String, Object> qryMapIn = new HashMap<String, Object>();
        qryMapIn.put("id", imgId);
        qryMapIn.put("status", Constants.TABLE_RECORD_STATUS_NOMAL);
        qryMapIn.put("tenantId", tenantId);
        List<AiImg> imgList = imgDao.listImgByCondition(qryMapIn);
        if (CollectionUtils.isEmpty(imgList)) {
            throw (new AppException(ErrorCode.IMG_EXCEPTION_IMG_NOT_EXISTS, "根据文件id未查询到当前租户下的文件信息，处理失败！"));
        }
        AiImg imgVo = imgList.get(0);
        fileInfo.put("equipId", imgVo.getEquipId());
        fileInfo.put("classId", imgVo.getClassId());

        int m = 0;
        int msize = markList.size();
        List<String> markIdList = new ArrayList<String>();
        Map<String, Object> markMap = new HashMap<String, Object>();
        Map<String, Object> markMapIn = new HashMap<String, Object>();
        Map<String, Object> markMapOut = new HashMap<String, Object>();
        markMapIn.put("sessionInfo", sessionInfo);
        markMapIn.put("oprInfo", oprInfo);
        markMapIn.put("fileInfo", fileInfo);
        // 逐个标记处理
        for (m = 0; m < msize; m++) {
            markMap = markList.get(m);
            markMapIn.put("markInfo", markMap);
            markMapOut = this.dealImgMark(markMapIn);
            markIdList.add((String) markMapOut.get("markId"));
        }

        // 操作记录
        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", (String) fileInfo.get("userId"));
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", (String) sessionInfo.get("authorId"));
        paramRecord.put("opTime", (String) oprInfo.get("updateTime"));
        paramRecord.put("remark", oprInfo.get("opNote"));
        paramRecord.put("busiCategory", Constants.PATIENT_ACTIVE_BUSI_TYPE_14);
        paramRecord.put("opUsertype", Constants.OPCODE_TYPE_DOCTOR);
        paramRecord.put("id", (String) oprInfo.get("updateAccept"));
        paramRecord.put("opDesc", oprInfo.get("opNote"));
        paramRecord.put("opCode", oprInfo.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", tenantId);
        paramRecord.put("opType", oprInfo.get("opType"));
        paramRecord.put("taskId", "");
        paramRecord.put("breifIntro", markIdList.toString());
        iaOperationRecordDao.saveOperationRecord(paramRecord);

        outMap.put("markIdList", markIdList);
        return outMap;
    }

    // 影像文件标记处理
    public Map<String, Object> dealImgMark(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> markInfo = ToolUtil.typeCast(argMap.get("markInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(argMap.get("sessionInfo"));
        Map<String, Object> outMap = new HashMap<String, Object>();

        // 标记id
        String markId = (String) markInfo.get("markId");
        if (StringUtils.isBlank(markId)) {
            // 插入
            markId = SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_MARK_ID);
            markInfo.put("markId", markId);
            markInfo.put("insertFlag", "Y");
        } else {
            // 更新
            markInfo.put("insertFlag", "N");
            // 校验标记记录是否存在
            Map<String, Object> qryMapIn = new HashMap<String, Object>();
            qryMapIn.put("id", markId);
            qryMapIn.put("tenantId", sessionInfo.get("tenantId"));
            List<AiImgMark> imgMarkList = imgMarkDao.listImgMarkByCondition(qryMapIn);
            if (CollectionUtils.isEmpty(imgMarkList)) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_IMGMARK_NOT_EXISTS, "根据标记id未查询到当前租户下的标记记录，处理失败！"));
            }
        }

        // 标记记录入库
        this.saveImgMarkToDb(argMap);

        // 标记记录详情入库
        this.saveImgMarkDataToDb(argMap);

        outMap.put("markId", markId);
        return outMap;
    }

    // 影像文件标记入库
    public Map<String, Object> saveImgMarkToDb(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> markInfo = ToolUtil.typeCast(argMap.get("markInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(argMap.get("sessionInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> outMap = new HashMap<String, Object>();
        String insertFlag = (String) markInfo.get("insertFlag");
        String markId = (String) markInfo.get("markId");
        String authorId = (String) sessionInfo.get("authorId");
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String imgId = (String) fileInfo.get("imgId");
        String tenantId = (String) sessionInfo.get("tenantId");

        Map<String, Object> upMapIn = new HashMap<String, Object>();
        upMapIn.put("id", markId);
        upMapIn.put("updateAccept", updateAccept);
        upMapIn.put("updateTime", updateTime);
        upMapIn.put("authorId", authorId);

        if ("Y".equals(insertFlag)) {
            upMapIn.put("updateType", Constants.UPDATE_TYPE_INSERT);
            // 插入
            AiImgMark imgMark = new AiImgMark();
            imgMark.setAxisX((Integer) markInfo.get("axisX"));
            imgMark.setAxisY((Integer) markInfo.get("axisY"));
            imgMark.setId(markId);
            imgMark.setMarkHeight((Integer) markInfo.get("markHeight"));
            imgMark.setMarkName((String) markInfo.get("markName"));
            imgMark.setMarkWidth((Integer) markInfo.get("markWidth"));
            imgMark.setUpdateAccept(updateAccept);
            imgMark.setUpdateAuthor(authorId);
            imgMark.setUpdateTime(updateTime);
            imgMark.setTenantId(tenantId);
            imgMark.setUserId((String) fileInfo.get("userId"));
            imgMark.setClassId((String) fileInfo.get("classId"));
            imgMark.setDiseaseId((String) fileInfo.get("diseaseId"));
            imgMark.setEquipId((String) fileInfo.get("equipId"));
            imgMark.setImgId(imgId);
            imgMark.setMarkTemplId((String) markInfo.get("templId"));
            imgMark.setMarkTemplVersion((Integer) markInfo.get("templVersion"));
            imgMark.setCreateAuthor(authorId);
            imgMark.setCreateTime(updateTime);
            imgMark.setStatus(Constants.TABLE_RECORD_STATUS_NOMAL);
            imgMark.setMarkType((String) markInfo.get("markType"));
            imgMark.setMarkColour((String) markInfo.get("markColour"));
            imgMark.setRotationAngle((Integer) markInfo.get("rotationAngle"));
            imgMarkDao.saveAiImgMark(imgMark);
        } else {
            // 更新
            upMapIn.put("updateType", Constants.UPDATE_TYPE_UPDATE_X);
            upMapIn.put("axisX", (Integer) markInfo.get("axisX"));
            upMapIn.put("axisY", (Integer) markInfo.get("axisY"));
            upMapIn.put("markHeight", (Integer) markInfo.get("markHeight"));
            upMapIn.put("markName", (String) markInfo.get("markName"));
            upMapIn.put("markColour", (String) markInfo.get("markColour"));
            upMapIn.put("markWidth", (Integer) markInfo.get("markWidth"));
            upMapIn.put("tenantId", tenantId);
            upMapIn.put("rotationAngle", (Integer) markInfo.get("rotationAngle"));
            imgMarkDao.updateAiImgMark(upMapIn);
        }
        // 入历史
        imgMarkDao.saveAiImgMarkHis(upMapIn);

        return outMap;
    }

    // 影像文件标记记录详情入库
    public Map<String, Object> saveImgMarkDataToDb(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> markInfo = ToolUtil.typeCast(argMap.get("markInfo"));
        Map<String, Object> sessionInfo = ToolUtil.typeCast(argMap.get("sessionInfo"));
        Map<String, Object> fileInfo = ToolUtil.typeCast(argMap.get("fileInfo"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> outMap = new HashMap<String, Object>();
        List<Map<String, Object>> valuesList = ToolUtil.typeCast(markInfo.get("values"));
        String insertFlag = (String) markInfo.get("insertFlag");
        String markId = (String) markInfo.get("markId");
        String authorId = (String) sessionInfo.get("authorId");
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String imgId = (String) fileInfo.get("imgId");
        String tenantId = (String) sessionInfo.get("tenantId");

        int v = 0;
        int vsize = valuesList.size();
        String dataId = "";
        Map<String, Object> valueMap = new HashMap<String, Object>();
        List<AiImgMarkData> insertImdList = new ArrayList<AiImgMarkData>();
        if ("Y".equals(insertFlag)) {
            // 插入
            for (v = 0; v < vsize; v++) {
                valueMap = valuesList.get(v);
                dataId = (String) valueMap.get("dataId");
                AiImgMarkData imgMarkData = new AiImgMarkData();
                imgMarkData.setClassId((String) fileInfo.get("classId"));
                imgMarkData.setCreateAuthor(authorId);
                imgMarkData.setCreateTime(updateTime);
                imgMarkData.setDataCode((String) valueMap.get("dataCode"));
                imgMarkData.setDataId(dataId);
                imgMarkData.setDataName((String) valueMap.get("dataName"));
                imgMarkData.setDataValue((String) valueMap.get("dataValue"));
                imgMarkData.setDiseaseId((String) fileInfo.get("diseaseId"));
                imgMarkData.setEquipId((String) fileInfo.get("equipId"));
                imgMarkData.setId(SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_MARKDATA_ID));
                imgMarkData.setImgId(imgId);
                imgMarkData.setMarkId(markId);
                imgMarkData.setTenantId(tenantId);
                imgMarkData.setUpdateAccept(updateAccept);
                imgMarkData.setUpdateAuthor(authorId);
                imgMarkData.setUpdateTime(updateTime);
                imgMarkData.setUpdateType(Constants.UPDATE_TYPE_INSERT);
                imgMarkData.setUserId((String) fileInfo.get("userId"));
                insertImdList.add(imgMarkData);
            }
        } else {
            Map<String, Object> upMapIn = new HashMap<String, Object>();
            upMapIn.put("markId", markId);
            upMapIn.put("updateAccept", updateAccept);
            upMapIn.put("updateTime", updateTime);
            upMapIn.put("authorId", authorId);
            upMapIn.put("updateType", Constants.UPDATE_TYPE_UPDATE_X);
            // 更新
            int up = 0;
            for (v = 0; v < vsize; v++) {
                valueMap = valuesList.get(v);
                dataId = (String) valueMap.get("dataId");
                upMapIn.put("dataId", dataId);
                upMapIn.put("dataCode", (String) valueMap.get("dataCode"));
                upMapIn.put("dataName", (String) valueMap.get("dataName"));
                upMapIn.put("dataValue", (String) valueMap.get("dataValue"));
                up = imgMarkDataDao.updateAiImgMarkData(upMapIn);
                if (0 == up) {
                    // 新问题id则需要插入
                    AiImgMarkData imgMarkData = new AiImgMarkData();
                    imgMarkData.setClassId((String) fileInfo.get("classId"));
                    imgMarkData.setCreateAuthor(authorId);
                    imgMarkData.setCreateTime(updateTime);
                    imgMarkData.setDataCode((String) valueMap.get("dataCode"));
                    imgMarkData.setDataId(dataId);
                    imgMarkData.setDataName((String) valueMap.get("dataName"));
                    imgMarkData.setDataValue((String) valueMap.get("dataValue"));
                    imgMarkData.setDiseaseId((String) fileInfo.get("diseaseId"));
                    imgMarkData.setEquipId((String) fileInfo.get("equipId"));
                    imgMarkData.setId(SeqUtil.getSeqNo(Constants.SEQ_NO_FOR_IMG_MARKDATA_ID));
                    imgMarkData.setImgId(imgId);
                    imgMarkData.setMarkId(markId);
                    imgMarkData.setTenantId(tenantId);
                    imgMarkData.setUpdateAccept(updateAccept);
                    imgMarkData.setUpdateAuthor(authorId);
                    imgMarkData.setUpdateTime(updateTime);
                    imgMarkData.setUpdateType(Constants.UPDATE_TYPE_INSERT);
                    imgMarkData.setUserId((String) fileInfo.get("userId"));
                    insertImdList.add(imgMarkData);
                } else {
                    // 更新入历史
                    upMapIn.remove("dataCode");
                    upMapIn.remove("dataName");
                    upMapIn.remove("dataValue");
                    imgMarkDataDao.saveAiImgMarkDataHis(upMapIn);
                }
            }
        }
        if (CollectionUtils.isNotEmpty(insertImdList)) {
            imgMarkDataDao.saveAiImgMarkDataBatch(insertImdList);
            imgMarkDataDao.saveAiImgMarkDataHisBatch(insertImdList);// 插入入历史
        }

        return outMap;
    }

    // 影像文件标记删除接口实现
    @Transactional
    public Map<String, Object> eraseImgMark(Map<String, Object> mapIn) throws Exception {
        Map<String, Object> argMap = new HashMap<String, Object>(mapIn);
        Map<String, Object> outMap = new HashMap<String, Object>();
        Map<String, Object> sessionInfo = ToolUtil.typeCast(argMap.get("sessionInfo"));
        Map<String, Object> oprInfo = ToolUtil.typeCast(argMap.get("oprInfo"));
        Map<String, Object> markInfo = ToolUtil.typeCast(argMap.get("markInfo"));
        String authorId = (String) sessionInfo.get("authorId");
        String updateTime = (String) oprInfo.get("updateTime");
        String updateAccept = (String) oprInfo.get("updateAccept");
        String tenantId = (String) sessionInfo.get("tenantId");
        List<String> markIdList = ToolUtil.typeCast(markInfo.get("markIdList"));

        Map<String, Object> upMapIn = new HashMap<String, Object>();
        upMapIn.put("updateAccept", updateAccept);
        upMapIn.put("updateTime", updateTime);
        upMapIn.put("authorId", authorId);
        upMapIn.put("updateType", Constants.UPDATE_TYPE_UPDATE_X);
        upMapIn.put("tenantId", tenantId);
        int up = 0;
        for (String markId : markIdList) {
            logger.info("markId==" + markId);
            upMapIn.put("id", markId);
            upMapIn.put("status", Constants.TABLE_RECORD_STATUS_INVALID);
            up = imgMarkDao.updateAiImgMark(upMapIn);// 更新为无效状态
            if (0 == up) {
                throw (new AppException(ErrorCode.IMG_EXCEPTION_IMGMARK_NOT_EXISTS, "根据标记id未查询到当前租户下的标记记录，处理失败！"));
            }
            imgMarkDao.saveAiImgMarkHis(upMapIn);// 入历史
        }

        // 操作记录
        Map<String, Object> paramRecord = new HashMap<String, Object>();
        Calendar now = Calendar.getInstance();
        paramRecord.put("month", String.valueOf(now.get(Calendar.MONTH) + 1));
        paramRecord.put("day", String.valueOf(now.get(Calendar.DAY_OF_MONTH)));
        paramRecord.put("userId", (String) markInfo.get("userId"));
        paramRecord.put("queueId", "");
        paramRecord.put("opUser", (String) sessionInfo.get("authorId"));
        paramRecord.put("opTime", (String) oprInfo.get("updateTime"));
        paramRecord.put("remark", oprInfo.get("opNote"));
        paramRecord.put("busiCategory", Constants.PATIENT_ACTIVE_BUSI_TYPE_14);
        paramRecord.put("opUsertype", Constants.OPCODE_TYPE_DOCTOR);
        paramRecord.put("id", (String) oprInfo.get("updateAccept"));
        paramRecord.put("opDesc", oprInfo.get("opNote"));
        paramRecord.put("opCode", oprInfo.get("opCode"));
        paramRecord.put("busiId", null);
        paramRecord.put("tenantId", tenantId);
        paramRecord.put("opType", oprInfo.get("opType"));
        paramRecord.put("taskId", "");
        paramRecord.put("breifIntro", markIdList.toString());
        iaOperationRecordDao.saveOperationRecord(paramRecord);

        return outMap;
    }
}
